package cn.doitedu.rtmk.common;

import com.alibaba.fastjson.JSONArray;

public class CompareUtils {

    private static boolean valueCompare(JSONArray paramTagValue, String compareType, String tagValueStr) {

        boolean res = false;
        String minStr;
        String maxStr;
        double min;
        double max;
        double realValue;
        switch (compareType) {
            case "between":
                minStr = paramTagValue.getString(0);
                maxStr = paramTagValue.getString(1);

                min = Double.parseDouble(minStr);
                max = Double.parseDouble(maxStr);
                realValue = Double.parseDouble(tagValueStr);

                res = realValue >= min && realValue <= max;
                break;
            case ">":
                minStr = paramTagValue.getString(0);
                min = Double.parseDouble(minStr);
                realValue = Double.parseDouble(tagValueStr);

                res = realValue > min;
                break;

            case "<":
                maxStr = paramTagValue.getString(0);
                max = Double.parseDouble(maxStr);
                realValue = Double.parseDouble(tagValueStr);

                res = realValue < max;
                break;

            case "=":
                String paramValueStr = paramTagValue.getString(0);
                res = tagValueStr.equals(paramValueStr);
                break;
            default:
        }

        return res;
    }

}
